package com.ruoyi.web.controller.newTable;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TAchievement;
import com.ruoyi.system.service.ITAchievementService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 国家级、省部级教学成果奖Controller
 * 
 * @author ruoyi
 * @date 2024-12-06
 */
@RestController
@RequestMapping("/system/achievement")
public class TAchievementController extends BaseController
{
    @Autowired
    private ITAchievementService tAchievementService;

    /**
     * 查询国家级、省部级教学成果奖列表
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:list')")
    @GetMapping("/list")
    public TableDataInfo list(TAchievement tAchievement)
    {
        startPage();
        List<TAchievement> list = tAchievementService.selectTAchievementList(tAchievement);
        return getDataTable(list);
    }

    /**
     * 导出国家级、省部级教学成果奖列表
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:export')")
    @Log(title = "国家级、省部级教学成果奖", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TAchievement tAchievement)
    {
        List<TAchievement> list = tAchievementService.selectTAchievementList(tAchievement);
        ExcelUtil<TAchievement> util = new ExcelUtil<TAchievement>(TAchievement.class);
        util.exportExcel(response, list, "国家级、省部级教学成果奖数据");
    }

    /**
     * 获取国家级、省部级教学成果奖详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tAchievementService.selectTAchievementById(id));
    }

    /**
     * 新增国家级、省部级教学成果奖
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:add')")
    @Log(title = "国家级、省部级教学成果奖", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TAchievement tAchievement)
    {
        return toAjax(tAchievementService.insertTAchievement(tAchievement));
    }

    /**
     * 修改国家级、省部级教学成果奖
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:edit')")
    @Log(title = "国家级、省部级教学成果奖", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TAchievement tAchievement)
    {
        return toAjax(tAchievementService.updateTAchievement(tAchievement));
    }

    /**
     * 删除国家级、省部级教学成果奖
     */
    @PreAuthorize("@ss.hasPermi('system:achievement:remove')")
    @Log(title = "国家级、省部级教学成果奖", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tAchievementService.deleteTAchievementByIds(ids));
    }
}
